import 'package:flutter/material.dart';
import 'package:core_package/core_package.dart';
import 'package:flutter_app_unionad/ui/basice/my_separator_widget.dart';

class InputSeparatorWidget extends StatelessWidget {
  final bool showBottomLine;
  final bool bottomLineIsSeparator;
  final Function(String value)? valueChange;
  @required
  final String? title;
  final double? titleWidth;
  final String? placeholder;
  final double? textFieldHeight;
  final TextInputType? keyboard;
  final int? maxLength;
  final Widget? icon;
  final bool obscureText; //密码输入样式
  final double? inputFont;
  final TextEditingController? controller;

  const InputSeparatorWidget({
    Key? key,
    this.showBottomLine = true,
    this.bottomLineIsSeparator = true,
    @required this.valueChange,
    @required this.title,
    this.titleWidth,
    @required this.placeholder,
    this.textFieldHeight,
    this.keyboard,
    this.maxLength,
    this.icon,
    this.inputFont,
    this.obscureText = false,
    this.controller,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        ShowTitleInputListWidget(
          obscureText: obscureText,
          textFieldHeight: textFieldHeight ?? 40.px,
          titleWidget: Container(
            width: titleWidth ?? 80.px,
            child: Text(
              title ?? '',
              style: TextStyle(
                color: MyColors.formHex("#272727FF"),
                fontSize: MyFont.font14,
                fontWeight: MyFontWeight.regular,
              ),
            ),
          ),
          padding: EdgeInsets.zero,
          showBottomLine: false,
          textAlign: TextAlign.start,
          placeholder: placeholder ?? "",
          keyboardType: keyboard ?? TextInputType.text,
          inputStyle: TextStyle(
            color: MyColors.formHex("#272727FF"),
            fontWeight: MyFontWeight.regular,
            fontSize: inputFont ?? MyFont.font14,
          ),
          placeholderStyle: TextStyle(
            color: MyColors.color_221_221_221,
            fontWeight: MyFontWeight.regular,
            fontSize: inputFont ?? MyFont.font14,
          ),
          controller: controller ?? null,
          inputTextTapChange: (value) {
            if (valueChange != null) valueChange?.call(value);
          },
          maxLength: maxLength,
          icon: icon,
        ),
        Offstage(
          offstage: !showBottomLine,
          child: Row(children: [
            SizedBox(width: titleWidth ?? 80.px),
            Expanded(
              child: bottomLineIsSeparator
                  ? MySeparator(color: MyColors.color_238_238_238)
                  : Divider(
                      height: 1,
                      color: MyColors.color_238_238_238,
                    ),
            ),
          ]),
        )
      ],
    );
  }
}
